<?php

class Ialbum_Widget_FriendPhotosController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
  	$viewer = Engine_Api::_()->user()->getViewer();
  	if(!$viewer && !$viewer->getIdentity()) return $this->setNoRender();
  	 // Multiple friend mode
    $friends = $viewer->membership()->getMembers();  
    $ids = array();
    foreach ($friends as $friend){
		if($friend->user_id == $viewer->getIdentity()) continue;
    	$ids[] = $friend->user_id;
    }
    $this->view->friendPhotos = $friendPhotos =  Engine_Api::_()->ialbum()->getFreindPhotos($ids);
    $friendPhotos->setItemCountPerPage($this->_getParam('itemCountPerPage', 5));
    $friendPhotos->setCurrentPageNumber($this->_getParam('page', 1));
    if ($friendPhotos->count() <= 0) return $this->setNoRender();
  }
}
